package com.game.worm.mobile.view.find;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.dx.as.fragment.TFragment;
import com.game.worm.mobile.R;
import com.game.worm.mobile.bean.GameBean;
import com.game.worm.mobile.view.find.adpater.RecommendAdpater;
import com.game.worm.mobile.view.home.adpater.HotAdpater;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by d_xxiang on 2018/3/27.
 */

public class FindGameFragment extends TFragment{
    private HotAdpater hotAdpater;
    private HotAdpater btAdpater;
    private HotAdpater lifeAdpater;
    private RecommendAdpater recommendAdpater;

    @Override
    public void initView() {

        hideToolbar(false);

        RecyclerView discoveryView = findView(R.id.recyclerview_discovery);
        RecyclerView btView = findView(R.id.recyclerview_bt);
        RecyclerView lifeView = findView(R.id.recyclerview_life);
        RecyclerView recommendView = findView(R.id.recyclerview_recommend);


        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
        linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);

        LinearLayoutManager linearLayoutManager2 = new LinearLayoutManager(getActivity());
        linearLayoutManager2.setOrientation(LinearLayoutManager.HORIZONTAL);

        LinearLayoutManager linearLayoutManager3 = new LinearLayoutManager(getActivity());
        linearLayoutManager3.setOrientation(LinearLayoutManager.HORIZONTAL);

        LinearLayoutManager linearLayoutManager4 = new LinearLayoutManager(getActivity());
        linearLayoutManager4.setOrientation(LinearLayoutManager.HORIZONTAL);


        discoveryView.setLayoutManager(linearLayoutManager);
        btView.setLayoutManager(linearLayoutManager2);
        lifeView.setLayoutManager(linearLayoutManager3);
        recommendView.setLayoutManager(linearLayoutManager4);

        hotAdpater = new HotAdpater(getActivity());
        lifeAdpater = new HotAdpater(getActivity());
        btAdpater = new HotAdpater(getActivity());

        recommendAdpater = new RecommendAdpater(getActivity());

        lifeView.setAdapter(lifeAdpater);
        btView.setAdapter(btAdpater);
        discoveryView.setAdapter(hotAdpater);
        recommendView.setAdapter(recommendAdpater);

        getTestDataHot();
    }

    @Override
    public void onHiddenChanged(boolean hidden) {
        if (!hidden){
            hideToolbar(false);
        }
    }

    private void getTestDataHot(){
        List<GameBean> list = new ArrayList<>();
        for (int i = 0; i < 5; i ++) {
            list.add(new GameBean());
        }
        hotAdpater.addData(list);
        hotAdpater.notifyDataSetChanged();
        lifeAdpater.addData(list);
        lifeAdpater.notifyDataSetChanged();
        btAdpater.addData(list);
        btAdpater.notifyDataSetChanged();

        List<RecommendPlayerBean> list2 = new ArrayList<>();
        for (int i = 0; i < 5; i ++) {
            list2.add(new RecommendPlayerBean());
        }
        recommendAdpater.addData(list2);
        recommendAdpater.notifyDataSetChanged();
    }

    @Override
    public int setLayoutI() {
        return R.layout.fragment_find_game;
    }

    @Override
    public void dataOpion() {

    }

    @Override
    public void initRpo() {

    }
}
